package hpu.e4_demo.controller;

import hpu.e4_demo.common.Result;
import hpu.e4_demo.entity.TUsers;
import hpu.e4_demo.service.ITUsersService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表（登录时查询） 前端控制器
 * </p>
 *
 * @author FFF
 * @since 2025-06-21
 */
@RestController
@RequestMapping("/tUsers")
public class TUsersController {
    @Autowired
    private ITUsersService tUsersService;

    //查询全部的注册的用户数据.
    @RequestMapping("/findAll")
    Result<List<TUsers>> findAll() {
        return tUsersService.findAll();
    }
    //注册功能。
    @RequestMapping("/register")
    Result<String> add(@RequestBody TUsers tUsers) {
        return tUsersService.add(tUsers);
    }
//----------------------------------上述两种方法传递的参数要参考entity类中命名----------------------------------

    //登录功能
    @RequestMapping("/login")
    Result<Map<String, Object>> login(@Param("user_name") String user_name, @Param("password") String password,@Param("role") String role) {
        return tUsersService.login(user_name, password, role);
    }




}
